package core.router;

import core.queue.RouterQueue;
import core.schedulers.PacketListener;
import core.schedulers.SchedulerKind;

public class Worker implements PacketListener {

	private RouterQueue queue;

	// private RouterQueue outputQueue;

	public Worker(long capacity, SchedulerKind schedulerKind) {
		queue = new RouterQueue(capacity, schedulerKind);
	}

	public Packet process() {
		Packet headPacket = queue.removePacket();
		return headPacket;
	}

	public void onPacketReceiver(Packet packet, SchedulerKind from) {
		System.out.println("--- Worker recebeu um pacote! --- ");
		System.out.println("--- Pacote originado por: " + from);
		queue.receivePacket(packet);
	}

	public boolean hasPacket() {
		return !queue.isEmpty();
	}
}
